using System.ComponentModel;
using System.Drawing;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Markup;
using Infragistics.Win;
using Infragistics.Win.UltraWinDataSource;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Win.UltraWinTree;

namespace Controls
{
    public partial class UltraGridEx : System.Windows.Controls.UserControl, IComponentConnector
    {
        public UltraGrid ultraGrid = new UltraGrid();

        protected UltraDataSource informationTable = new UltraDataSource();

        protected Infragistics.Win.Appearance appearanceHighLight = new Infragistics.Win.Appearance();

        public UltraGridEx()
        {
            InitializeComponent();
            InitUltraGrid();
        }

        protected virtual void Init()
        {
        }

        private void InitUltraGrid()
        {
            Infragistics.Win.Appearance appearance = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance2 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance3 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance4 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance5 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance6 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance7 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance8 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance9 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance10 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance11 = new Infragistics.Win.Appearance();
            Infragistics.Win.Appearance appearance12 = new Infragistics.Win.Appearance();
            ((ISupportInitialize)ultraGrid).BeginInit();
            appearance.BackColor = SystemColors.Window;
            appearance.BorderColor = SystemColors.InactiveCaption;
            ultraGrid.DisplayLayout.Appearance = appearance;
            ultraGrid.DisplayLayout.BorderStyle = UIElementBorderStyle.Solid;
            ultraGrid.DisplayLayout.CaptionVisible = DefaultableBoolean.False;
            appearance2.BackColor = SystemColors.ActiveBorder;
            appearance2.BackColor2 = SystemColors.ControlDark;
            appearance2.BackGradientStyle = GradientStyle.Vertical;
            appearance2.BorderColor = SystemColors.Window;
            ultraGrid.DisplayLayout.GroupByBox.Appearance = appearance2;
            appearance3.ForeColor = SystemColors.GrayText;
            ultraGrid.DisplayLayout.GroupByBox.BandLabelAppearance = appearance3;
            ultraGrid.DisplayLayout.GroupByBox.BorderStyle = UIElementBorderStyle.Solid;
            appearance4.BackColor = SystemColors.ControlLightLight;
            appearance4.BackColor2 = SystemColors.Control;
            appearance4.BackGradientStyle = GradientStyle.Horizontal;
            appearance4.ForeColor = SystemColors.GrayText;
            ultraGrid.DisplayLayout.GroupByBox.PromptAppearance = appearance4;
            ultraGrid.DisplayLayout.MaxColScrollRegions = 1;
            ultraGrid.DisplayLayout.MaxRowScrollRegions = 1;
            appearance5.BackColor = SystemColors.Window;
            appearance5.ForeColor = SystemColors.ControlText;
            ultraGrid.DisplayLayout.Override.ActiveCellAppearance = appearance5;
            appearance6.BackColor = SystemColors.Highlight;
            appearance6.ForeColor = SystemColors.HighlightText;
            ultraGrid.DisplayLayout.Override.ActiveRowAppearance = appearance6;
            ultraGrid.DisplayLayout.Override.BorderStyleCell = UIElementBorderStyle.Dotted;
            ultraGrid.DisplayLayout.Override.BorderStyleRow = UIElementBorderStyle.Dotted;
            appearance7.BackColor = SystemColors.Window;
            ultraGrid.DisplayLayout.Override.CardAreaAppearance = appearance7;
            appearance8.BorderColor = Color.Silver;
            appearance8.TextTrimming = TextTrimming.EllipsisCharacter;
            ultraGrid.DisplayLayout.Override.CellAppearance = appearance8;
            ultraGrid.DisplayLayout.Override.CellClickAction = CellClickAction.EditAndSelectText;
            ultraGrid.DisplayLayout.Override.CellPadding = 0;
            appearance9.BackColor = SystemColors.Control;
            appearance9.BackColor2 = SystemColors.ControlDark;
            appearance9.BackGradientAlignment = GradientAlignment.Element;
            appearance9.BackGradientStyle = GradientStyle.Horizontal;
            appearance9.BorderColor = SystemColors.Window;
            ultraGrid.DisplayLayout.Override.GroupByRowAppearance = appearance9;
            appearance10.TextHAlignAsString = "Left";
            ultraGrid.DisplayLayout.Override.HeaderAppearance = appearance10;
            ultraGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Select;
            ultraGrid.DisplayLayout.Override.HeaderStyle = HeaderStyle.WindowsXPCommand;
            appearance11.BackColor = SystemColors.Window;
            appearance11.BorderColor = Color.Silver;
            ultraGrid.DisplayLayout.Override.RowAppearance = appearance11;
            ultraGrid.DisplayLayout.Override.RowSelectors = DefaultableBoolean.False;
            appearance12.BackColor = SystemColors.ControlLight;
            ultraGrid.DisplayLayout.Override.TemplateAddRowAppearance = appearance12;
            ultraGrid.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill;
            ultraGrid.DisplayLayout.ScrollStyle = ScrollStyle.Immediate;
            ultraGrid.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
            ultraGrid.Name = "ultraGrid";
            ultraGrid.Dock = DockStyle.Fill;
            ultraGrid.TabIndex = 0;
            ultraGrid.Text = "ultraGrid1";
            ultraGrid.DisplayLayout.BorderStyle = UIElementBorderStyle.None;
            ultraGrid.DisplayLayout.GroupByBox.Hidden = true;
            ((ISupportInitialize)ultraGrid).EndInit();
            windowsFormsHost.Child = ultraGrid;
            appearanceHighLight.FontData.Bold = DefaultableBoolean.True;
        }

        public virtual void Dispose()
        {
            ultraGrid.Dispose();
            windowsFormsHost.Dispose();
        }

        protected void SelectAllGridData()
        {
            ultraGrid.Selected.Rows.AddRange((UltraGridRow[])ultraGrid.Rows.All);
        }

        public void ReloadGridData()
        {
            ultraGrid.Rows.Refresh(RefreshRow.ReloadData);
        }
    }
}
